package com.tedu.project5.controller;


import com.tedu.project5.common.Result;
import com.tedu.project5.dto.OrderInfoDTO;
import com.tedu.project5.dto.QueryOrderInfoDTO;
import com.tedu.project5.mapper.DdOrderInfoMapper;
import com.tedu.project5.model.DdOrderInfo;
import com.tedu.project5.service.IDdOrderInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author mhg
 * @since 2022-06-20
 */
@Slf4j
@RestController
@RequestMapping("/project5/ddOrderInfo")
public class DdOrderInfoController {
    
    @Autowired
    private IDdOrderInfoService iDdOrderInfoService;
    
    /**
     * 查询订单列表
     * @return
     * http://localhost:9999/project5/ddOrderInfo/listAll
     */
    @CrossOrigin
    @PostMapping("/listAll")   //南宁市
    public Result list(@RequestBody QueryOrderInfoDTO dto){
        log.info("参数值--:"+ dto);
        return iDdOrderInfoService.queryExample(dto);
    }

    /**
     * 新增订单
     * @param orderInfo
     * @return
     */
    @CrossOrigin
    @PostMapping("/addOrder")
    public Result addUser(@RequestBody DdOrderInfo orderInfo){
        log.info("参数值--："+ orderInfo);
        return iDdOrderInfoService.saveOrder(orderInfo);
    }

    /**
     * 更新订单信息
     * @param dto
     * @return
     */
    @CrossOrigin
    @PostMapping("/updateById")
    public Result updateById(@RequestBody OrderInfoDTO dto){
        log.info("参数值--："+ dto);
        return iDdOrderInfoService.updateOrder(dto);
    }

    /**
     * 删除订单信息
     * @param id
     * @return
     */
    @CrossOrigin
    @PostMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable String id){
        log.info("参数值id--："+ id);
        return iDdOrderInfoService.deleteOrder(id);
    }
}
